# Contributor: Michał Polański <michal@polanski.me>
# Maintainer: Magicloud <magiclouds@gmail.com>
pkgname=minikube
pkgver=1.32.0
pkgrel=2
pkgdesc="Tool that makes it easy to run Kubernetes locally"
url="https://github.com/kubernetes/minikube"
license="Apache-2.0"
arch="all !s390x !riscv64" # blocked by libvirt
arch="$arch !x86 !armhf !armv7 !ppc64le !aarch64" # FTBFS (kvm2 driver)
makedepends="go bash libvirt-dev"
subpackages="
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	docker-machine-driver-kvm2:_kvm2_driver
	"
source="https://github.com/kubernetes/minikube/archive/v$pkgver/minikube-$pkgver.tar.gz
	skip-amd64-only-test.patch
	"
options="net"

export GOPATH="$srcdir"
export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	make out/minikube out/docker-machine-driver-kvm2

	cd out
	 ./minikube completion bash > $pkgname.bash
	 ./minikube completion fish > $pkgname.fish
	 ./minikube completion zsh > $pkgname.zsh
}

check() {
	TESTSUITE=unittest make test
}

package() {
	cd out
	install -Dm755 minikube "$pkgdir"/usr/bin/minikube
	install -Dm755 docker-machine-driver-kvm2 "$pkgdir"/usr/bin/docker-machine-driver-kvm2

	install -Dm644 $pkgname.bash "$pkgdir"/usr/share/bash-completion/completions/$pkgname
	install -Dm644 $pkgname.fish "$pkgdir"/usr/share/fish/vendor_completions.d/$pkgname.fish
	install -Dm644 $pkgname.zsh "$pkgdir"/usr/share/zsh/site-functions/_$pkgname
}

_kvm2_driver() {
	pkgdesc="minikube-maintained KVM driver for docker-machine"

	amove usr/bin/docker-machine-driver-kvm2
}

sha512sums="
afc759879b1f5cb713c112592ae7547bb7f6f4792289110183e87dafd00e4d05187ea9d728472cc15e585e50a1c219729fb66c5ae3d63dc32ee8d00b873ab2ae  minikube-1.32.0.tar.gz
2eccb63b0905791968dec95f8f758da12632a8530c6db600648f2a190b23dd363d1a3c717488fc4e36f9082346c053eb9cf2ed00f65d14744e3fe9606dc32ddd  skip-amd64-only-test.patch
"
